﻿using System;
using System.ComponentModel.DataAnnotations;

namespace Medora.Model
{
    public class ObjectRequiredAttribute : ValidationAttribute
    {

        public bool AllowEmptyStrings { get; set; }

        public ObjectRequiredAttribute()
            : base("The {0} field is required.")
        {
            AllowEmptyStrings = false;
        }

        public override bool IsValid(object value)
        {
            if (value == null)
                return false;

            if (value is Guid && ((Guid)value == Guid.Empty))
            {
                return false;
            }

            return true;
        }

    }
}
